<?php
	defined('RUN') or die('No access');
	
	class SliderModel
	{
		private $tables='slider';
	    public function getSlides($fields='*', $limit=null)
		{
			return Model::getDataSql("SELECT ".$fields." FROM ".$this->tables." ORDER BY `sort` ASC, `id` DESC ".$limit);
		}
		public function getSlideAdm($fields='*')
		{
			return Model::getDataSql("SELECT ".$fields." FROM ".$this->tables." ORDER BY `sort` ASC, `id` DESC");
		}
		public function getById($id,$fields='*')
		{
			$condition = array(
					'field' => 'id',
					'value' => $id
				);

			$cat = Model::getData($this->tables, $fields, $condition);
			if ($cat)
				return $cat[0];

			return FALSE;
		}
		public function add($data)
		{
			return Model::insertData($this->tables, $data);
		}

		public function update($data, $id)
		{
			$condition = array(
					'field' => 'id',
					'value' => $id
				);
			
			return Model::updateData($this->tables, $data, $condition);
		}

		public function delete($id)
		{
			$condition = array(
					'field' => 'id',
					'value' => $id
				);

			return Model::deleteData($this->tables, $condition);
		}
	}
